import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { HydratedDocument } from 'mongoose';

export type ClientHomeDocumentType = HydratedDocument<ClientHome>;
export type LogoDocumentType = HydratedDocument<Logo>;

export type AssemblyDocumentType = HydratedDocument<Assembly>;

interface Ass_id {
  cpu_id: string;
  gpu_id: string;
  memory_id: string;
  mainboard_id: string;
  ssd_id: string;
  hdd_id: string;
}

interface Ass_img {
  cpu_img: string;
  gpu_img: string;
  memory_img: string;
  mainboard_img: string;
  ssd_img: string;
  hdd_img: string;
}

@Schema()
export class ClientHome {
  @Prop({ required: true })
  title: string; //标题

  @Prop({ required: true })
  content: string; //内容
}

@Schema()
export class Logo {
  @Prop({ required: true })
  title: string; //标题

  @Prop({ required: true })
  img_url: string; //内容
}

@Schema()
export class Assembly {
  @Prop({ required: true })
  title: string; //标题

  @Prop({ required: true })
  userId: string; //用户id

  @Prop({ required: true })
  username: string; //用户名

  @Prop({ required: true })
  price: string; //价格

  @Prop({ required: true })
  score: string; //评分

  @Prop({ required: true })
  avatar: string; //头像

  @Prop({ required: true, type: Object })
  ass_id: Ass_id;

  @Prop({ required: true, type: Object })
  ass_img: Ass_img;
}

export const LogoSchema = SchemaFactory.createForClass(Logo);
export const ClientHomeSchema = SchemaFactory.createForClass(ClientHome);
export const AssemblySchema = SchemaFactory.createForClass(Assembly);
